﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Text.RegularExpressions;

namespace SentenceSplitterAndWordFinder
{
    class WordFinder
    {
        static void Main(string[] args)
        {
            string text = "The Dursleys were so mean and hideous that summer that all Harry Potter wanted was" +
                " to get back to the Hogwarts School for Witchcraft and Wizardry." +
            "But just as he's packing his bags, Harry receives a warning from a strange, " +
            "impish creature named Dobby who says that if Harry Potter returns to Hogwarts, disaster will strike." +
            "And strike it does. For in Harry's second year at Hogwarts," +
            "fresh torments and horrors arise, including an outrageously stuck-up " +
            "new professor, Gilderoy Lockhart, a spirit named Moaning Myrtle who haunts the girls' bathroom, and the unwanted attentions of Ron Weasley's younger sister, Ginny.";

            string sentenceSplitterPattern = @"\.|\!|\?";
            string[] sentences = Regex.Split(text, sentenceSplitterPattern);

            Console.Write("Input a word to match:");
            string input = Console.ReadLine();
            string wordPattern = @"\b"+input+@"\b";

            Regex regex = new Regex(wordPattern);

            foreach (var sentence in sentences)
            {
                if (regex.IsMatch(sentence))
                {
                    Console.WriteLine(sentence);
                }
            }

        }
    }
}
